﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TYSPPART : ViewBase
    {
        #region ==KDPARTIE===========
        public static readonly DependencyProperty KDPARTIEProperty = DependencyProperty.Register("KDPARTIE",
            typeof(string), typeof(TYSPPART),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKDPARTIEChanged));
        public string KDPARTIE
        {
            get
            {
                return (string)GetValue(KDPARTIEProperty);
            }
            set
            {
                SetValue(KDPARTIEProperty, value);
            }
        }
        private static void OnKDPARTIEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TYSPPART;
            if (src != null)
            {
                src.KDPARTIE = (string)e.NewValue;
            }
        }
        #endregion
        public TYSPPART()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VABAUFM();
            this.DataContext = MV;
            InitializeComponent(); 
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KDPARTIE = "";
                return;
            }
            KDPARTIE = dwMaster["KDPARTIE"].ToString();
        }
       
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
            SResult = ((VABAUFM)MV).QueryABAUFM(dwData, -2); 
            MergeData(SResult);
            vwMaster.View.MoveCurrentTo(-1);
        }
    }
}
